package com.awspaas.user.apps.shhtaerospaceindustrial.visiting;

import java.util.List;
import java.util.Map;

import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
import com.actionsoft.bpms.commons.database.ColumnMapRowMapper;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.sdk.local.SDK;
import com.awspaas.user.apps.shhtaerospaceindustrial.util.CoreUtil;

public class updateVisitPeoplefeedback  extends ExecuteListener{

	@Override
	public String getDescription() {
		return "节点审批结束，更新参观申请主表参观情况。";
	}
	@Override
	public void execute(ProcessExecutionContext param) throws Exception {
		// TODO Auto-generated method stub
		boolean flag_ok = SDK.getTaskAPI().isChoiceActionMenu(param.getTaskInstance(), "提交");
		if(flag_ok) {
			//获取流程实例ID
			String processInstId = param.getProcessInstance().getId();
			//根据流程实例ID获取任务表内数据
			List<Map<String , Object>> headlist = DBSql.query("SELECT * FROM BO_EU_VISIT_FEEDBACK  WHERE BINDID = ? ", 
					new ColumnMapRowMapper(), new Object[] {processInstId});
			Map<String , Object>  jcbd = headlist.get(0);
			String MEMO = CoreUtil.objToStr(jcbd.get("MEMO"));// 参观情况
			String FID = CoreUtil.objToStr(jcbd.get("FID"));// 父id
			BO newcmsrecord = new BO();
			newcmsrecord.set("ID", FID );
			newcmsrecord.set("MEMO", MEMO );
			if(!"".equals(FID)) {
				SDK.getBOAPI().update("BO_EU_INNERLOCATION_VISIT_APP", newcmsrecord);
			}
		}
	}

}
